package cn.joker.constant;

import java.io.*;

/**
 * created By huangxumin on
 */
public class FileUtil {


    public static String getFileContent(String filePath) throws IOException {
        return getFileContent(new File(filePath), "UTF-8");
    }

    public static String getFileContent(File filePath) throws IOException {
        return getFileContent(filePath, "UTF-8");
    }

    public static String getFileContent(File filePath, String charsetName) throws IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), charsetName))) {
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }

            return sb.toString();
        }
    }
}
